//显示二级弹框
function showSecondLevelPop(className){
	var top = document.body.scrollTop||document.documentElement.scrollTop;
	var this_h = $("." + className).height();
	var win_h = ($('html',parent.document).height()-this_h-100)/2
	$(".zhy_zhezhao_pop").height($("html").height());
	var this_h = $("." + className).height();
	top= top +win_h;
	//二级弹框
	$(".zhy_zhezhao_pop").show().css("z-index","101");
	$("." + className).css("top", top).show().css("z-index","102");
	
}
// 隐藏二级弹框
function hideSecondLevelPop(classname) {
	      $("."+classname).hide();
	      $(".zhy_zhezhao_pop").show().css("z-index","20");
}
 

 function showPopMGuide(className){//页面加载时展示功能引导图
	var w_h = parseInt($("body").height());
    var t_h= parseInt($("."+className).height());
    var top=parseInt(w_h-t_h)/2;
    if(t_h>w_h){
    	$("."+className).height(w_h-50).css("overflow","scroll");
    	$("."+className).width($("."+className).width()+20)
    	top= 20;
    }
	$(".zhy_zhezhao_pop").css("height",w_h).show();
	$(".zhy_guide_tip").hide();
	$("." + className).css("top", top).show();
}

function showPopGuide(className){//点击展示功能引导图
   	var width;
   	if(className=="zhy_popa_guidea"){
   		width=1175;
   	}else if(className=="zhy_popa_guidec"){
   		width=1175;
   	}else{
   		width=1175;
   	}
   	var mleft= -width/2;
   	$(".zhy_zhezhao_pop").css("top","0px");
    $("."+className).css({
   		"position":"absolute",
   		"marginLeft":mleft+"px",
   		"left":"50%",
   		"width":width+"px",
   		'right':'auto',
   		height:"auto",
   		opacity:1
   	});
   if($(".helpcenter").length!=0){
   	   $(".helpcenter .login_box").removeClass("on");
	   $(".helpcenter .login_box .dropdown-menu-header").css("display","none");
	   $(".helpcenter .login_box").find(".arrow_up").removeClass("arrow_up").addClass("arrow_down");
   	}else{
	   $(".li_a .ul_down").css("display","none");
   	}
   showPopMGuide(className);
}
function showGuideTip(){//展示帮助下拉列表
	if($(".helpcenter").length!=0){
		$(".helpcenter .login_box").addClass("on");
		$(".helpcenter .login_box .dropdown-menu-header").css("display","block");
		$(".helpcenter .login_box").find(".arrow_down").removeClass("arrow_down").addClass("arrow_up");
		var t= $(".helpcenter .so-awesome").offset().top+30,
	    l= $(".helpcenter .so-awesome").offset().left-370;
	}else{
		$(".li_a .ul_down").css("display","block");
		var t= $(".li_a .ul_down .so-awesome").offset().top+30,
	    l= $(".li_a .ul_down .so-awesome").offset().left-370;
	}
    var w_h = parseInt($("body").height());
    $(".zhy_zhezhao_pop").css({
    	"height":w_h,
    	"opacity":"0.8",
    	"zIndex":100
    }).show();
	$(".zhy_guide_tip").css({
    	left:l+"px",
    	top:t+"px",
    	zIndex:102
    }).show();
}
function hideGuide(){//隐藏引导弹框 展示帮助下拉列表
	$(".zhy_popa_guide").css({"position":"fixed","marginLeft":'0px',"left":"auto"}).animate({
		right:"300px",
		top :'60px',
		height:0,
		width:0,
		opacity:0
	},800,function(){
		showGuideTip()
	})
}
function hideGuide2(){//隐藏引导弹框 展示帮助下拉列表
	$(".zhy_popa_guide").css({"position":"fixed","marginLeft":'0px',"left":"auto"}).animate({
		right:"300px",
		top :'60px',
		height:0,
		width:0,
		opacity:0
	},800,function(){
		$(".zhy_zhezhao_pop").hide();
	});

}
function hideGuideM(){//隐藏弹框和帮助下拉列表
	if($(".helpcenter").length!=0){
		$(".helpcenter .login_box").removeClass("on");
		$(".helpcenter .login_box .dropdown-menu-header").css("display","none");
		$(".helpcenter .login_box").find(".arrow_up").removeClass("arrow_up").addClass("arrow_down");
	}else{
		$(".li_a .ul_down").css("display","none");
	}
	$(".zhy_guide_tip").hide();
	$(".zhy_zhezhao_pop").css({
    	"opacity":"0.6",
    	"zIndex":20
    }).show();
	// $(".zhy_zhezhao_pop").css("zIndex","20");
	hidePopC();
}

function goMoudel(classname){// 切换右侧 左侧菜单响应
	if($("."+classname).length!=0){
		if($(".second_left").length!=0){
			$(".left_menu .second_left").find(".on").removeClass("on");
			$("."+classname).addClass("on");
			$("."+classname).parents(".second_left").css("display","block").parent("li").addClass("on");
		}else{
			$(".homepage_firstUl >li").hide();
			$(".homepage_secUl").find(".on").removeClass("on");
			$(".homepage_secUl").find("."+classname).parent().addClass("on");
			$(".homepage_secUl .on").parents(".homepage_secUl").slideDown().parent("li").addClass("on");
			var li_parent= $("."+classname).parents("ul").parent("li");
			var val_str = li_parent.attr("value");
			
			$(".first_icon_"+val_str).show().siblings().removeClass("on");//二级显示
			$("#first_li_"+val_str).addClass("on").siblings().removeClass("on");//一级切换
			li_parent.addClass("on");
		}
	}
}
//隐藏呼叫中心弹框 并不显示最小化
function closeCtiPop(){
	$("#callIframe").hide();
	$("#callIframe").attr("src","");
 		
}
function showCallIfr(){//显示呼叫中心部分页面
   $("#mainf").hide();
   $("#callIframe").fadeIn(30);
   $(".call_min_icon").hide();
}
function closeCallIfr(){//隐藏呼叫中心部分页面
	$("#callIframe").hide();
	$("#mainf").fadeIn(30);
	if($("#callIframe").attr("show")=="true"||$("#callIframe").attr("show")==undefined){
		// console.log($("#callIframe").attr("show"))
		$(".call_min_icon").show();
	}
}
function setMainIfr(obj){//呼叫中心 - 工单管理
	var src=$(obj).attr("ahref");
	$("#callIframe").hide();
	$("#mainf").attr("src",src).show();
	$(".call_min_icon").show();
}
function judgeUrl(){
	console.log(2)
   if($("#mainf").contents().find(".zhy_platform").length!=0){
   	    $(".left_menu").hide();
   	    $('[data-role="paltform"]').addClass("on").siblings().removeClass("on");
		calArea();
   }else{
   	    $(".left_menu").show();
	    calArea();
   }
}
$("#mainf").load(function(){
	judgeUrl();
})
function judgeUrl(){
   if($("#mainf").contents().find("#not_show_left").length!=0){
   	    $(".left_menu").hide();
   	    $('[data-role="paltform"]').addClass("on").siblings().removeClass("on");
		calArea();
   }else{
   	    $(".left_menu").show();
   	    var id_num = $(".homepage_firstUl li:visible").attr("value");
   	    $('#first_li_'+id_num).addClass("on").siblings().removeClass("on");
	    calArea();
   }
}
function keepStep(){
   var iframe = $("#mainf")[0]; 
	if (iframe.attachEvent){ 
		iframe.attachEvent("onload", function(){ 
			$("#mainf").css("margin-left","0");
		}); 
	} else { 
		iframe.onload = function(){ 
			$("#mainf").css("margin-left","0");
		}; 
	} 
}
function CreateDiv(classname,url){
	
    $("#mainf").css("margin-left","200%");
	var flag=new Boolean(classname!=null||classname!="");

	if(flag&&$("."+classname).length!=0){
		$(".left_menu").show();
	    calArea();
		if($(".second_left").length!=0){
			$(".second_left").find(".on").removeClass("on");
			$(".second_left").find("."+classname).addClass("on");
			$(".second_left .on").parents(".second_left").slideDown().parent("li").addClass("on");
		}else{
			$(".homepage_firstUl >li").hide();
			$(".homepage_secUl").find(".on").removeClass("on");
			$(".homepage_secUl").find("."+classname).parent().addClass("on");
			$(".homepage_secUl .on").parents(".homepage_secUl").slideDown().parent("li").addClass("on");
			var li_parent= $("."+classname).parents("ul").parent("li");
			var val_str = li_parent.attr("value");
			$(".first_icon_"+val_str).show().siblings().removeClass("on");//二级显示
			$("#first_li_"+val_str).addClass("on").siblings().removeClass("on");//一级切换
			li_parent.addClass("on");
		}
	}else{
        $(".left_menu").hide();
	    calArea();
	}
	if(url==null||url==""){
	   $("."+classname).click();
	}else{
	  $("#mainf").attr("src",url);
	}
	keepStep();
	
}
// 文字左右无缝滚动
 function  Marquee(){ 
		var right_a =$(".bgfcfaf2 .marquee").css("right");
		var b_wid=$(".bgfcfaf2").width()-400;
		var span_wid= $(".bgfcfaf2 .marquee span").eq(0).width();
		b_wid=b_wid-span_wid;
		right_a=parseInt(right_a);
		var sum_width=0;
	    $(".bgfcfaf2 .marquee span").each(function(){
	     	sum_width+=$(this).width();
	    });
		if(right_a > -(sum_width+$(".bgfcfaf2 .marquee span").length*400)){
		    right_a=right_a-1;
		 	$(".bgfcfaf2 .marquee").css("right",right_a+"px");
		}else{
		 	$(".bgfcfaf2 .marquee").css("right",b_wid+"px");
		} 
}
 /*
  右侧区域宽高
  * */
 function calArea(){
 	var w_h = $(window).height(),
 	    w_w = $(window).width(),
 	    headr_h = $(".header").length>0?$(".header").outerHeight():$(".homepage_header").outerHeight(),
 	    ul_left_w = $(".left_menu").outerWidth(),
 	    bg_h = $("#mainFrame .bgfcfaf2:visible").outerHeight();
	 	var right_h = w_h-headr_h-bg_h-30;
	    $("#div_pannel").height(right_h);
	    $("#mainFrame").height(w_h-headr_h-30);
	    if($(".left_menu:visible").length!=0){
	    	$(".right_main").css("padding-left",ul_left_w+"px");
	    }else{
	    	$(".right_main").css("padding-left","0px");
	    }
 }
$(function(){
	if($(".zhy_zhezhao_pop").length!=0){
		var w_h = parseInt($("body").height());
		// console.log(w_h)
	     $(".zhy_zhezhao_pop").css("height",w_h);
	}
	
	calArea()
	$(window).resize(function(){
		calArea();
		// 左侧滚动条自适应
		if($(".zhy_mall_btn_biga").length!=0){
	    	left_menu_height= $("#mainFrame").height()-105;
	    	$(".left_menu").height(left_menu_height);
	    }else{
	    	left_menu_height= $("#mainFrame").height()-30;
	    	$(".left_menu").height(left_menu_height);
	    }
	    if($(".zhy_popa_guide:visible").length!=0){
			var str =$(".zhy_popa_guide:visible").attr("class");
			var arr =new Array();
			arr= str.split(" ");
			showPopGuide(arr[2])
		}
    	$('.left_menu  ul.first_left').slimScroll({// 左侧滚动条自适应
			width: '175px',
	       height: left_menu_height, 
		   size: '5px',
		   position: 'right',
		   color: '#e5e5e5',
		   alwaysVisible: true, 
		   railVisible: true, 
		   wheelStep: 10, 
		   allowPageScroll: false,
		   disableFadeOut: false 
		});

    })
	// 文字左右无缝滚动
	if($(".bgfcfaf2 .marquee").length==1){
		var b_wid=$(".bgfcfaf2").width()-400;
		var span_wid= $(".bgfcfaf2 .marquee span").eq(0).width()?$(".bgfcfaf2 .marquee span").eq(0).width():350;
		b_wid=b_wid-span_wid;
		
	    $(".bgfcfaf2 .marquee").css("right",b_wid+"px");
	    var MyMar=setInterval(Marquee,20); 
	    $(".bgfcfaf2 .marquee").mouseover(function() {clearInterval(MyMar);} )
	    $(".bgfcfaf2 .marquee").mouseout(function() {MyMar=setInterval(Marquee,20);}) 
	}
})    

$(function(){
    /*--------------拖曳效果----------------
    *原理：标记拖曳状态dragging ,坐标位置iX, iY
    *         mousedown:fn(){dragging = true, 记录起始坐标位置，设置鼠标捕获}
    *         mouseover:fn(){判断如果dragging = true, 则当前坐标位置 - 记录起始坐标位置，绝对定位的元素获得差值}
    *         mouseup:fn(){dragging = false, 释放鼠标捕获，防止冒泡}
    */
   if($("#drag").length!=0){

    var dragging = false;
    var iX, iY;
    $("#drag").mousedown(function(e) {
        dragging = true;
        iX = e.clientX - this.offsetLeft;
        iY = e.clientY - this.offsetTop;
        this.setCapture && this.setCapture();
        return false;
        // console.log(iX)
    });
    document.onmousemove = function(e) {
        if (dragging) {
	        var e = e || window.event;
	        var w_w= $(window).width()- $("#drag").width();
	        var w_h= $(window).height()- $("#drag").height()-85;
	        var oX = e.clientX - iX;
	        var oY = e.clientY - iY;
	        if(oX>w_w){
	        	oX=w_w;
	        }else if(oX<0){
	        	oX=0;
	        }
	        
	         if(oY>w_h){
	        	oY=w_h;
	        }else if(oY<0){
	        	oY=0;
	        }
	        $("#drag").css({"left":oX + "px", "top":oY + "px"});
	        return false;
        }
    };
    $(document).mouseup(function(e) {
    	var e = e || window.event;
        dragging = false;
        $("#drag")[0].setCapture &&$("#drag")[0].releaseCapture();
        e.cancelBubble = true;
    })
 }
 })